Imports CasClientBase
Imports ccapps.persistent.CorpSMS_Lib
Imports ccapps.Util

Namespace Web.page

    Public Class CorpSMS_PenaltySimulation
        Inherits [lib].BasePage

        Protected WithEvents DefProf As System.Web.UI.HtmlControls.HtmlSelect
        Protected WithEvents txt_ValidFrom As System.Web.UI.WebControls.TextBox
        Protected WithEvents txt_Custcode As System.Web.UI.WebControls.TextBox
        Protected WithEvents dg_Option1Definitions As System.Web.UI.WebControls.DataGrid
        Protected WithEvents btn_Kaydet As System.Web.UI.WebControls.Button
        Protected WithEvents txt_ValidTo As System.Web.UI.WebControls.TextBox
        Protected WithEvents txt_InitialCounter As System.Web.UI.WebControls.TextBox
        Protected WithEvents txt_TotalPackagePrice As System.Web.UI.WebControls.TextBox
        Protected WithEvents txt_InstallmentCount As System.Web.UI.WebControls.TextBox
        Protected WithEvents txt_FirstInstallmentDate As System.Web.UI.WebControls.TextBox
        Protected WithEvents ddl_OverUsage As System.Web.UI.WebControls.DropDownList
        Protected WithEvents txt_OverUsageParameter As System.Web.UI.WebControls.TextBox
        Protected WithEvents cb_UseStandardPercantages As System.Web.UI.WebControls.CheckBox
        Protected WithEvents txt_TurkcellPercentage As System.Web.UI.WebControls.TextBox
        Protected WithEvents txt_OtherPercentage As System.Web.UI.WebControls.TextBox
        Protected WithEvents pnl_Custcode As System.Web.UI.WebControls.Panel
        Protected WithEvents pnl_Aciklama As System.Web.UI.WebControls.Panel
        Protected WithEvents pnl_Tanimlar As System.Web.UI.WebControls.Panel
        Protected WithEvents lbl_customer_id As System.Web.UI.WebControls.Label
        Protected WithEvents lbl_adi As System.Web.UI.WebControls.Label
        Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
        Protected WithEvents btn_NewCustcode As System.Web.UI.WebControls.Button
        Protected WithEvents txt_VodafonePercentage As System.Web.UI.WebControls.TextBox
        Protected WithEvents txt_TelekomPercentage As System.Web.UI.WebControls.TextBox
        Protected WithEvents txt_IntPercentage As System.Web.UI.WebControls.TextBox
        Protected WithEvents cb_AveaPercentage As System.Web.UI.WebControls.CheckBox
        Protected WithEvents chkP As System.Web.UI.WebControls.CheckBox
        Protected WithEvents ddlSolPrtnr As System.Web.UI.WebControls.DropDownList
        Protected WithEvents ddlDealerCode As System.Web.UI.WebControls.DropDownList
        Protected WithEvents Textbox1 As System.Web.UI.WebControls.TextBox
        Protected WithEvents Textbox2 As System.Web.UI.WebControls.TextBox
        Protected WithEvents Textbox3 As System.Web.UI.WebControls.TextBox
        Protected WithEvents Textbox4 As System.Web.UI.WebControls.TextBox
        Protected WithEvents btn_Check As System.Web.UI.WebControls.Button
        Protected WithEvents Textbox5 As System.Web.UI.WebControls.TextBox
        Protected WithEvents Textbox6 As System.Web.UI.WebControls.TextBox
        Protected WithEvents btn_GetAllDefinitions As System.Web.UI.WebControls.Button


#Region " Web Form Designer Generated Code "

        'This call is required by the Web Form Designer.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        End Sub
        Protected WithEvents ltlAlert As System.Web.UI.WebControls.Literal
        Protected WithEvents Button66 As System.Web.UI.WebControls.Button
        Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm
        Protected WithEvents proc As System.Web.UI.HtmlControls.HtmlInputHidden
        'Protected WithEvents Button1 As System.Web.UI.HtmlControls.HtmlInputButton

        'NOTE: The following placeholder declaration is required by the Web Form Designer.
        'Do not delete or move it.
        Private designerPlaceholderDeclaration As System.Object

        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
        End Sub

#End Region

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            Me.PageTitle = "Kurumsal SMS Ceza Sorgulama"


            If Not IsPostBack Then
                giris_kontrol()
            Else
            End If

        End Sub

        Private Sub giris_kontrol()

        End Sub


        Private Sub btn_Check_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Check.Click
            Dim l_result As String
            Dim customer_id As Integer

            Dim l_res As String
            Dim l_name As String
            Dim l_cust_id As String
            Dim l_check As Integer
            Dim proc_param As Integer

            Dim p_turkcell As Integer
            Dim p_avea As Integer
            Dim p_vodafone As Integer
            Dim p_telekom As Integer
            Dim p_int As Integer
            Dim p_other As Integer
            'LOGLAMA
            'l_check = persistent.myDBConn.ORAScalar("select count(*) from billintra.corpsms_option2 WHERE custcode = '" & txt_Custcode.Text.Trim & "' and end_date > trunc(sysdate)")
            l_check = persistent.myDBConn.ORAScalar_LOG("select count(*) from billintra.corpsms_option2 WHERE custcode = '" & txt_Custcode.Text.Trim & "' and end_date > trunc(sysdate)", txt_Custcode.Text.Trim, "", "", "", "select(btn_Check_Click)", "CorpSMS_PenaltySimulation", Session("user"))

            If l_check = 0 Then
                Message = "alert('Abone icin aktif Kurumsal SMS taahhudu bulunamamistir.'); "
                Return
            End If
            l_res = GetCompanyName(Me.txt_Custcode.Text.Trim, l_cust_id, l_name)

            If l_res = "OK" Then
                Me.lbl_adi.Text = l_name
                Me.lbl_customer_id.Text = l_cust_id
            Else
                Me.lbl_adi.Text = "-----"
                Me.lbl_customer_id.Text = "-----"
            End If

            If Me.Textbox1.Text.Trim = "" Or Me.Textbox1.Text.Trim = "" Or Me.Textbox1.Text.Trim = "" Or Me.Textbox1.Text.Trim = "" Or Me.Textbox1.Text.Trim = "" Or Me.Textbox1.Text.Trim = "" Then
                proc_param = 4
            End If
            If Me.Textbox1.Text.Trim <> "" Or Me.Textbox1.Text.Trim <> "" Or Me.Textbox1.Text.Trim <> "" Or Me.Textbox1.Text.Trim <> "" Or Me.Textbox1.Text.Trim <> "" Or Me.Textbox1.Text.Trim <> "" Then
                proc_param = 5
            End If

            If Me.Textbox1.Text.Trim = "" Then
                p_avea = 0
            Else
                p_avea = CInt(Textbox1.Text.Trim)
            End If

            If Me.Textbox4.Text.Trim = "" Then
                p_turkcell = 0
            Else
                p_turkcell = CInt(Textbox4.Text.Trim)
            End If

            If Me.Textbox2.Text.Trim = "" Then
                p_vodafone = 0
            Else
                p_vodafone = CInt(Textbox2.Text.Trim)
            End If

            If Me.Textbox5.Text.Trim = "" Then
                p_telekom = 0
            Else
                p_telekom = CInt(Textbox5.Text.Trim)
            End If

            If Me.Textbox3.Text.Trim = "" Then
                p_int = 0
            Else
                p_int = CInt(Textbox3.Text.Trim)
            End If

            If Me.Textbox6.Text.Trim = "" Then
                p_other = 0
            Else
                p_other = CInt(Textbox6.Text.Trim)
            End If

            'LOGLAMA
            'customer_id = persistent.myDBConn.ORAScalar("select customer_id from customer_all WHERE custcode = '" & txt_Custcode.Text.Trim & "'")
            customer_id = persistent.myDBConn.ORAScalar_LOG("select customer_id from customer_all WHERE custcode = '" & txt_Custcode.Text.Trim & "'", txt_Custcode.Text.Trim, "", "", "", "select(btn_Check_Click)", "CorpSMS_PenaltySimulation", Session("user").ToString())
            l_result = Me.lbl_customer_id.Text = StartPenaltySimulationProcess(txt_Custcode.Text.Trim, proc_param, p_avea, p_turkcell, p_vodafone, p_telekom, p_int, p_other, CStr(Session("user")))

            dg_Option1Definitions.DataSource = GetPenaltySimulationResult(customer_id)
            dg_Option1Definitions.DataBind()


        End Sub

    End Class
End Namespace